package edu.hit.crawler.http;

import java.io.Serializable;

public class RobotsEntry implements Comparable<RobotsEntry>, Serializable {
	
	private static final long serialVersionUID = 5463807467106361263L;
	
	private String prefix;
	private boolean allowed;

	RobotsEntry(String prefix, boolean allowed) {
		this.setPrefix(prefix);
		this.setAllowed(allowed);
	}

	@Override
	public int compareTo(RobotsEntry o) {
		
		if(this.getAllowed() == o.getAllowed()) return 0;
		
		if(this.getAllowed()) {
			return 1;
		} else {
			if(o.getAllowed()) {
				return -1; 
			} else {
				return 1;
			}
		}
	}

	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}

	public String getPrefix() {
		return prefix;
	}

	public void setAllowed(boolean allowed) {
		this.allowed = allowed;
	}

	public boolean getAllowed() {
		return allowed;
	}
}
